<?php

namespace App\Http\Requests\Api;

use Illuminate\Foundation\Http\FormRequest;

class GoodsRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        switch ($this->method()){
            case 'POST':
                return [
                    //
                    'good_category_id' =>  'required|integer',
                    'goods_name' => 'required|string',
                    'store_count' => 'required|numeric',
                    'market_price' => 'required|numeric',
                    'shop_price' => 'required|numeric',
                    'goods_content' => 'required|string',
                    'img' => 'required|string',
                    'is_hot'=> 'required|boolean',
                    'is_one' =>'required|boolean'
                ];
                break;
            case 'PUT':
                return [
                    'good_category_id' =>  'integer',
                    'goods_name' => 'string',
                    'store_count' => 'numeric',
                    'market_price' => 'numeric',
                    'shop_price' => 'numeric',
                    'goods_content' => 'string',
                    'img' => 'string',
                    'is_hot'=> 'boolean',
                    'is_one' =>'boolean'
                ];
        }

    }
}
